fix(converters): deduplicate Postman folder/request names case-insensitively#7900
fix(converters): deduplicate Postman folder/request names case-insensitively#7900BradPerbs wants to merge 1 commit intousebruno:mainfrom
Conversation
…itively The Postman v2 collection importer already deduplicates sibling folder and request names against an in-memory map, but the lookup is case-sensitive. As a result a Postman collection that contains two sibling folders named, for example, OAuth2 and oAuth2 produces two Bruno items with their original names. On case-insensitive filesystems (default on Windows and macOS APFS) the writer collapses them into the same directory and silently overwrites the first folder's contents. Lowercase the lookup key when checking for and recording a collision so case-only variants are renamed (oAuth2 -> oAuth2_1) before they reach the filesystem layer. The same fix is applied to the request-name path. Adds two unit tests covering the folder and request cases. The wider filesystem-writer dedup gap mentioned in usebruno#7821 is not addressed here. Refs usebruno#7821
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughThe Postman-to-Bruno converter now performs case-insensitive name deduplication for both folders and requests. Map keys are lowercased during uniqueness checks and storage, preventing collisions between names differing only in casing. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.Comment |
Summary
Fixes a piece of issue #7821 — Postman/Insomnia import silently corrupts folders with case-colliding sibling names.
The Postman v2 importer in
bruno-convertersalready deduplicates sibling folder and request names against an in-memory map, but the map lookup is case-sensitive. A Postman collection with two sibling folders named e.g.OAuth2andoAuth2therefore produces two Bruno items with their original names, and on a case-insensitive filesystem (default on Windows and macOS APFS) the writer collapses them into the same directory and silently overwrites the first folder's contents.This PR lowercases the key used for the collision lookup (and for recording entries), so case-only variants are renamed at the converter stage:
OAuth2(kept)oAuth2→oAuth2_1Same fix applied symmetrically to the request-name path. Display names keep their original casing — only the dedup map's key is normalized.
Scope
This PR addresses the converter-level deduplication gap. The two follow-ups mentioned in #7821 — sibling-level dedup in the filesystem writer and the missing
recursive: trueonmkdirSync— are intentionally out of scope to keep this PR small and focused, percontributing.md.Tests
Added two unit tests in
packages/bruno-converters/tests/postman/postman-to-bruno/postman-to-bruno.spec.js:should deduplicate sibling folder names case-insensitively—OAuth2+oAuth2⇒OAuth2,oAuth2_1should deduplicate sibling request names case-insensitively—GetUser+getuser⇒GetUser,getuser_1Both tests fail on
mainand pass with this change. The fullbruno-converterstest suite has the same pre-existing failure count (161) before and after this change; the only delta is +2 passing tests inpostman-to-bruno.spec.js.The pre-existing failures are all in unrelated
postman-translations/bruno-to-postman-translationstest files and are not touched by this change.Test instructions
nvm use HUSKY=0 npm install --legacy-peer-deps --ignore-scripts npm run build --workspace=packages/bruno-common cd packages/bruno-converters NODE_OPTIONS=--experimental-vm-modules node ../../node_modules/jest/bin/jest.js tests/postman/postman-to-bruno/postman-to-bruno.spec.jsExpected:
Tests: 32 passed, 32 total(including the two new cases).Summary by CodeRabbit
Bug Fixes
Tests